<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <link rel="stylesheet" href="../../css/animate.css">
  <link rel="stylesheet" href="../../iconfont/iconfont.css">
  <link rel="stylesheet" href="../../css/mescroll.css">
  <link rel="stylesheet" href="../../css/gloab.css">
  <title>升级合伙人</title>
</head>
<body>
  <div id="app">
    <div id="public-header" style="padding-bottom:1rem;">
      <div id="statusbar"></div>
      <header class="public-header">
        <div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
        <div class="public-header-title">升级合伙人</div>
      </header>
      <div class="take-name auto" style="font-size:0.32rem;color:#fff;margin-top:0.24rem;">付费升级</div>
    </div>
    <div class="vip-one">
      <div class="vip-one-top flex">
        <div class="vip-one-top-lf F3">
          <span class="personal-header-vip" style="font-size:0.36rem;">合伙人</span>&nbsp;
          <span class="personal-header-vip" style="font-size:0.24rem;">付费升级</span>
        </div>
        <div class="vip-one-top-rt F1">￥{{takeVipPrice}}</div>
      </div>
      <div class="vip-one-top" v-html="content">

      </div>
      <!-- <p style="color:#888;font-size:0.28rem;">无直推要求，可拿一代奖励10%</p> -->
      <div class="vip-one-pay" @click="takeHhr">立即支付(￥{{takeVipPrice}})</div>
    </div>
  </div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/mescroll.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/jsencrypt.js"></script>
<script src="../../script/fastclick.js"></script>

<script>
var vm;
var mescroll;
apiready=function(){
  api.removeLaunchView();
  setBar("statusbar");
  setFont(750);
  startVue();
  $(".public-progress").fadeOut(1000);
  setTimeout(function(){
    $(".public-progress").css({"display":"none"});
  },2000);
}
function startVue(){
  vm = new Vue({
    el:"#app",
    data:{
      gdtt:['100','1000','5000','10000','20000','50000'],
      num:0,
      takeVipPrice:'',
      userInfo:[],
      content:'',
      upgrade_content:'',
      prices:[],
    },
    created:function(){
      this.getTakeVipPrice();
      this.getUserInfo();
    },
    methods:{
      close:function(){
        api.closeToWin({
            name: 'root'
        });
      },
      getUserInfo:function(){
        api.ajax({
            url: apiUrl+'/api/user/index',
            method: 'post',
            data: {
                values: {
                    token:$api.getStorage('token'),
                },
            }
        },function(ret, err){
      			console.log(JSON.stringify(ret))
            if (ret.code==1) {
              vm.userInfo = ret.data;
            } else {
             vm.userInfo = ret.data;
            }
        });
      },
      takeHhr:function(){
        if (vm.userInfo['type_id']=='3') {
          msg('你已是合伙人了，无需再次申请');
          return;
        }
        // var amount = '';
        // if (vm.userInfo['rank']=='0') {
        //   amount = parseInt(vm.takeVipPrice);
        //   var content = '升级合伙人需支付'+amount+'元是否升级？';
        // }else if(vm.userInfo['rank']=='1'||vm.userInfo['rank']=='2'||vm.userInfo['rank']=='3'){
        //   var vipprice = parseInt(vm.prices['vipprice']);
        //   amount = parseInt(vm.takeVipPrice) - vipprice;
        //   var content = '原价'+vm.takeVipPrice+',补差价升级合伙人需支付'+amount+'元是否升级？';
        // }
        var dialogBox = api.require('dialogBox');
        dialogBox.alert({
            texts: {
                content: '是否确认升级合伙人',
                leftBtnTitle: '取消',
                rightBtnTitle: '确认'
            },
            styles: {
                bg: '#fff',
                w: 300,
                corner:2,
                content: {
                    color: '#000',
                    size: 14
                },
                left: {
                    marginB: 7,
                    marginL: 20,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#fff',
                    size: 12
                },
                right: {
                    marginB: 7,
                    marginL: 10,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#fff',
                    size: 12
                }
            }
        }, function(ret) {
            if (ret.eventType == 'left') {
                var dialogBox = api.require('dialogBox');
                dialogBox.close({
                    dialogName: 'alert'
                });
            }else if(ret.eventType == 'right'){
              var dialogBox = api.require('dialogBox');
              dialogBox.close({
                  dialogName: 'alert'
              });
              api.toast({
                  msg: '订单已提交，请前往支付',
                  duration: 2000,
                  location: 'middle'
              });
              setTimeout(function(){
                api.openWin({
                    name: 'pay',
                    url: '../home/pay.html',
                    pageParam: {
                      release_price:vm.takeVipPrice,
                      types:9,
					  type:8,
					  ad:3,
                    }
                });
              },500);
            }
        });
      },
	  getTakeVipPrice:function(){
	    api.ajax({
	        url: apiUrl+'/api/index/userLevelInfo',
	        method: 'post',
	        data: {
	  				values: {
	  				    type:3
	  				},
	        }
	    },function(ret, err){
	  			console.log(JSON.stringify(ret))
	        if (ret.code==1) {
	          vm.takeVipPrice = ret.data.price;
	          vm.content = ret.data.description;
			   vm.prices = ret.data.price;
	        } else {
	          vm.takeVipPrice = '';
	          vm.content = '';
	        }
	    });
	  },
    }
  })
}

</script>
</html>
